package ml;

import java.io.IOException;

public class LibSVMFileFormat extends MLFileFormat {

	public LibSVMFileFormat(String trainingFile, DataModel dm) throws IOException {
		super(trainingFile + ".libsvm", dm);
	}

	@Override
	public void writeData() throws IOException {
		for (FeatureVector fv : dm.getFeatureVectors()) {
			bw.append(fv.getLabel() + " ");
			for (Data d : fv.getData())
				bw.append((d.getColumn()+1) + ":" + d.getValue() + " ");
			bw.append("\n");
		}
	}

	@Override
	public void writeFeatures() throws IOException {
	}

}
